define(['./controllers'], function (controllers) {
    'use strict';
    controllers.controller('indexCtrl', ['$scope', '$timeout', '$ionicModal',
        function ($scope,$timeout,$ionicModal) {

            $scope.city = "北京";

            $ionicModal.fromTemplateUrl('partials/modal/city.html', {
                scope: $scope
            }).then(function (modal) {
                $scope.modal = modal;
            });
            $scope.closeCity = function () {
                $scope.modal.hide();
            };

            $scope.openCity = function () {
                $scope.modal.show();
            };
            $scope.doCity = function (city) {
                console.log('Doing login', city);
                $scope.city = city;
                $timeout(function () {
                    $scope.closeCity();
                }, 100);
            }
            //search
            $scope.search = {key:"",lineType:"全部"}
            $ionicModal.fromTemplateUrl('partials/modal/search.html', {
                scope: $scope
            }).then(function (modal) {
                $scope.searchModal = modal;
            });
            $scope.closeSearch = function () {
                $scope.searchModal.hide();
            };

            $scope.openSearch = function () {
                $scope.searchModal.show();
            };
            $scope.doSearch = function () {
                console.log('Doing searchKey ', $scope.search);

                $timeout(function () {
                    $scope.closeSearch();
                }, 100);
            }
        }
    ])
});
